package events;

import java.util.Random;

import simulation.Echeancier;
import simulation.StationState;


public class LeaveTeleSkiBC extends Event {
	public static double NB_PASSAGE_IN_BC;
	private int provenance;
	
	public LeaveTeleSkiBC(int provenance){
		super();
		this.provenance = provenance;
	}

	@Override
	public String toString() {
		return "Un skieur arrive en haut des pistes [T="+Echeancier.toHour(date)+"]";
	}

	@Override
	public void treat(Echeancier e) {
		NB_PASSAGE_IN_BC++;
		
		switch (provenance) {
			case 0: StationState.B--;break;
			default: StationState.C--;break;
		}
		
		Event next;
		
		switch (choicePiste()) {
		case 0:
			next = new BackToStation(1);
			next.date = date + 120 + StationState.exp1_3.next();
			StationState.p1++;
			break;
		case 1:
			next = new LeavePiste2A();
			next.date = date + 120 + StationState.exp1.next();;
			StationState.p2A++;
			break;
		case 2:
			next = new BackToStation(3);
			next.date = date + 120 + StationState.exp1_2.next();
			StationState.p3++;
			break;
		default:
			next = new BackToStation(4);
			next.date = date + 60 + StationState.exp1_2.next();
			StationState.p4++;
			break;
		}
		e.ajouter(next);
	}

	private int choicePiste() {
		return (new Random()).nextInt(4);
	}
	
}
